/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * feeDialog.java
 *
 * Created on 2011-5-11, 21:01:30
 */
package junchangmis.student;

import java.io.IOException;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import junchangmis.*;
import jxl.write.WriteException;
import publicmethod.*;
import java.util.Vector;
import java.util.StringTokenizer;
import javax.swing.JOptionPane;
import java.sql.ResultSet;

/**
 *
 * @author developers
 */
public class feeDialog extends javax.swing.JDialog {

    MainFrame parent;
    formalStu student;

    /** Creates new form feeDialog */
    public feeDialog(java.awt.Frame parent, boolean modal, MainFrame pparent, formalStu student) {
        super(parent, modal);
        this.parent = pparent;
        this.student = student;
        initComponents();
        this.jTextFieldId.setEditable(false);
        this.jTextFieldName.setEditable(false);
        initInfo();
        this.setTitle("正式生交费");
        this.setLocationRelativeTo(null);
    }

    void initInfo() {
        this.jTextFieldId.setText(student.id);
        this.jTextFieldName.setText(student.name);

        this.jTextFieldWeekCount.setText(student.weekCount);

        Vector<String> temp = new Vector<String>();
        StringTokenizer st = new StringTokenizer(student.dateStart, ".");
        while (st.hasMoreElements()) {
            temp.add(st.nextToken());
        }
        this.jComboBoxYearStart.setSelectedItem(temp.get(0));
        this.jComboBoxMonthStart.setSelectedItem(temp.get(1));
        this.jComboBoxDayStart.setSelectedItem(temp.get(2));
        this.jTextFieldCoursePerWeek.setText(student.coursePerWeek);
        int weekCount = Integer.valueOf(this.jTextFieldWeekCount.getText());

        int gap = 7 * Integer.valueOf(this.jTextFieldWeekCount.getText());
        int year = Integer.valueOf(this.jComboBoxYearStart.getSelectedItem().toString());
        int month = Integer.valueOf(this.jComboBoxMonthStart.getSelectedItem().toString());
        int day = Integer.valueOf(this.jComboBoxDayStart.getSelectedItem().toString());
        this.jTextFieldEndDate.setText(formalStuInputMethod.getEndDate(year, month, day, gap));


        int coursePerWeek = Integer.valueOf(this.jTextFieldCoursePerWeek.getText());
        int count = weekCount * coursePerWeek;
        this.jTextFieldCount.setText(Integer.toString(count));
        this.jTextFieldPricePerCourse.setText(student.pricePerCourse);
        int pricePerCourse = Integer.valueOf(this.jTextFieldPricePerCourse.getText());
        int tuition = pricePerCourse * count;
        this.jTextFieldTuition.setText(Integer.toString(tuition));
        this.jTextFieldBookFee.setText(student.bookFee);
        this.jTextFieldCostumeFee.setText(student.costumeFee);
        this.jTextFieldOtherFee.setText(student.otherFee);
        int costumeFee = Integer.valueOf(this.jTextFieldCostumeFee.getText());
        int bookFee = Integer.valueOf(this.jTextFieldBookFee.getText());
        int otherFee = Integer.valueOf(this.jTextFieldOtherFee.getText());
        int sumFee = tuition + costumeFee + bookFee + otherFee;
        this.jTextFieldSumFee.setText(Integer.toString(sumFee));
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel2 = new javax.swing.JPanel();
        jLabelWeekCount = new javax.swing.JLabel();
        jTextFieldWeekCount = new javax.swing.JTextField();
        jLabelDateStart = new javax.swing.JLabel();
        jComboBoxYearStart = new javax.swing.JComboBox();
        jLabelYearStart = new javax.swing.JLabel();
        jComboBoxMonthStart = new javax.swing.JComboBox();
        jLabelMonthStart = new javax.swing.JLabel();
        jComboBoxDayStart = new javax.swing.JComboBox();
        jLabelDayStart = new javax.swing.JLabel();
        jButtonGenerateEndDate = new javax.swing.JButton();
        jTextFieldEndDate = new javax.swing.JTextField();
        jPanelBottom = new javax.swing.JPanel();
        jLabelCoursePerWeek = new javax.swing.JLabel();
        jTextFieldCoursePerWeek = new javax.swing.JTextField();
        jButtonGenerateCount = new javax.swing.JButton();
        jTextFieldCount = new javax.swing.JTextField();
        jLabelPricePerCourse = new javax.swing.JLabel();
        jTextFieldPricePerCourse = new javax.swing.JTextField();
        jButtonGenerateTuition = new javax.swing.JButton();
        jLabelCount = new javax.swing.JLabel();
        jLabelTuition = new javax.swing.JLabel();
        jTextFieldTuition = new javax.swing.JTextField();
        jLabelCostumeFee = new javax.swing.JLabel();
        jTextFieldCostumeFee = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabelBookFee = new javax.swing.JLabel();
        jTextFieldBookFee = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        jLabelOtherFee = new javax.swing.JLabel();
        jTextFieldOtherFee = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        jButtonGenerateSumFee = new javax.swing.JButton();
        jLabelSumFee = new javax.swing.JLabel();
        jTextFieldSumFee = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        jLabelId = new javax.swing.JLabel();
        jTextFieldId = new javax.swing.JTextField();
        jLabelName = new javax.swing.JLabel();
        jTextFieldName = new javax.swing.JTextField();
        jButtonConfirm = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setResizable(false);

        jLabelWeekCount.setFont(new java.awt.Font("华文细黑", 0, 24)); // NOI18N
        jLabelWeekCount.setText("交费周数");

        jTextFieldWeekCount.setFont(new java.awt.Font("华文细黑", 0, 24)); // NOI18N

        jLabelDateStart.setFont(new java.awt.Font("华文细黑", 0, 24)); // NOI18N
        jLabelDateStart.setText("交费起始日");

        jComboBoxYearStart.setFont(new java.awt.Font("华文细黑", 0, 24)); // NOI18N
        jComboBoxYearStart.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "2011", "2012", "2013", "2014", "2015", "2016" }));

        jLabelYearStart.setFont(new java.awt.Font("华文细黑", 0, 24)); // NOI18N
        jLabelYearStart.setText("年");

        jComboBoxMonthStart.setFont(new java.awt.Font("华文细黑", 0, 24)); // NOI18N
        jComboBoxMonthStart.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12" }));

        jLabelMonthStart.setFont(new java.awt.Font("华文细黑", 0, 24)); // NOI18N
        jLabelMonthStart.setText("月");

        jComboBoxDayStart.setFont(new java.awt.Font("华文细黑", 0, 24)); // NOI18N
        jComboBoxDayStart.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31" }));

        jLabelDayStart.setFont(new java.awt.Font("华文细黑", 0, 24)); // NOI18N
        jLabelDayStart.setText("日");

        jButtonGenerateEndDate.setFont(new java.awt.Font("华文细黑", 0, 24)); // NOI18N
        jButtonGenerateEndDate.setText("生成交费截止日");
        jButtonGenerateEndDate.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonGenerateEndDateActionPerformed(evt);
            }
        });

        jTextFieldEndDate.setFont(new java.awt.Font("华文细黑", 0, 24)); // NOI18N

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabelWeekCount)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTextFieldWeekCount, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabelDateStart)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jComboBoxYearStart, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabelYearStart)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jComboBoxMonthStart, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jButtonGenerateEndDate)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jTextFieldEndDate)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabelMonthStart)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jComboBoxDayStart, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabelDayStart)
                .addContainerGap(36, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelWeekCount)
                    .addComponent(jTextFieldWeekCount, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabelDateStart)
                    .addComponent(jComboBoxYearStart, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabelYearStart)
                    .addComponent(jComboBoxMonthStart, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabelMonthStart)
                    .addComponent(jComboBoxDayStart, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabelDayStart))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButtonGenerateEndDate)
                    .addComponent(jTextFieldEndDate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        jLabelCoursePerWeek.setFont(new java.awt.Font("华文细黑", 0, 24)); // NOI18N
        jLabelCoursePerWeek.setText("每周课次");

        jTextFieldCoursePerWeek.setFont(new java.awt.Font("华文细黑", 0, 24)); // NOI18N
        jTextFieldCoursePerWeek.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextFieldCoursePerWeekActionPerformed(evt);
            }
        });

        jButtonGenerateCount.setFont(new java.awt.Font("华文细黑", 0, 24)); // NOI18N
        jButtonGenerateCount.setText("生成总课次");
        jButtonGenerateCount.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonGenerateCountActionPerformed(evt);
            }
        });

        jTextFieldCount.setFont(new java.awt.Font("华文细黑", 0, 24)); // NOI18N

        jLabelPricePerCourse.setFont(new java.awt.Font("华文细黑", 0, 24)); // NOI18N
        jLabelPricePerCourse.setText("课次单价");

        jTextFieldPricePerCourse.setFont(new java.awt.Font("华文细黑", 0, 24)); // NOI18N
        jTextFieldPricePerCourse.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextFieldPricePerCourseActionPerformed(evt);
            }
        });

        jButtonGenerateTuition.setFont(new java.awt.Font("华文细黑", 0, 24)); // NOI18N
        jButtonGenerateTuition.setText("生成学费");
        jButtonGenerateTuition.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonGenerateTuitionActionPerformed(evt);
            }
        });

        jLabelCount.setFont(new java.awt.Font("华文细黑", 0, 24)); // NOI18N
        jLabelCount.setText("总课次");

        jLabelTuition.setFont(new java.awt.Font("华文细黑", 0, 24)); // NOI18N
        jLabelTuition.setText("学费");

        jTextFieldTuition.setFont(new java.awt.Font("华文细黑", 0, 24)); // NOI18N

        jLabelCostumeFee.setFont(new java.awt.Font("华文细黑", 0, 24)); // NOI18N
        jLabelCostumeFee.setText("服装费");

        jTextFieldCostumeFee.setFont(new java.awt.Font("华文细黑", 0, 24)); // NOI18N

        jLabel2.setFont(new java.awt.Font("华文细黑", 0, 24)); // NOI18N
        jLabel2.setText("元");

        jLabel3.setFont(new java.awt.Font("华文细黑", 0, 24)); // NOI18N
        jLabel3.setText("元");

        jLabelBookFee.setFont(new java.awt.Font("华文细黑", 0, 24)); // NOI18N
        jLabelBookFee.setText("书费");

        jTextFieldBookFee.setFont(new java.awt.Font("华文细黑", 0, 24)); // NOI18N

        jLabel4.setFont(new java.awt.Font("华文细黑", 0, 24)); // NOI18N
        jLabel4.setText("元");

        jLabelOtherFee.setFont(new java.awt.Font("华文细黑", 0, 24)); // NOI18N
        jLabelOtherFee.setText("其他费");

        jTextFieldOtherFee.setFont(new java.awt.Font("华文细黑", 0, 24)); // NOI18N
        jTextFieldOtherFee.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextFieldOtherFeeActionPerformed(evt);
            }
        });

        jLabel5.setFont(new java.awt.Font("华文细黑", 0, 24)); // NOI18N
        jLabel5.setText("元");

        jButtonGenerateSumFee.setFont(new java.awt.Font("华文细黑", 0, 24)); // NOI18N
        jButtonGenerateSumFee.setText("生成总收费");
        jButtonGenerateSumFee.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonGenerateSumFeeActionPerformed(evt);
            }
        });

        jLabelSumFee.setFont(new java.awt.Font("华文细黑", 0, 24)); // NOI18N
        jLabelSumFee.setText("总收费");

        jTextFieldSumFee.setFont(new java.awt.Font("华文细黑", 0, 24)); // NOI18N

        jLabel6.setFont(new java.awt.Font("华文细黑", 0, 24)); // NOI18N
        jLabel6.setText("元");

        javax.swing.GroupLayout jPanelBottomLayout = new javax.swing.GroupLayout(jPanelBottom);
        jPanelBottom.setLayout(jPanelBottomLayout);
        jPanelBottomLayout.setHorizontalGroup(
            jPanelBottomLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelBottomLayout.createSequentialGroup()
                .addGroup(jPanelBottomLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelBottomLayout.createSequentialGroup()
                        .addGap(20, 20, 20)
                        .addGroup(jPanelBottomLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanelBottomLayout.createSequentialGroup()
                                .addGroup(jPanelBottomLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(jPanelBottomLayout.createSequentialGroup()
                                        .addComponent(jLabelCostumeFee)
                                        .addGap(28, 28, 28)
                                        .addComponent(jTextFieldCostumeFee, javax.swing.GroupLayout.PREFERRED_SIZE, 72, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(1, 1, 1)
                                        .addComponent(jLabel3)
                                        .addGap(10, 10, 10)
                                        .addComponent(jLabelBookFee))
                                    .addGroup(jPanelBottomLayout.createSequentialGroup()
                                        .addComponent(jButtonGenerateSumFee)
                                        .addGap(37, 37, 37)
                                        .addComponent(jLabelSumFee)))
                                .addGap(3, 3, 3)
                                .addGroup(jPanelBottomLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jTextFieldBookFee, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jTextFieldSumFee, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(4, 4, 4)
                                .addComponent(jLabel4))
                            .addGroup(jPanelBottomLayout.createSequentialGroup()
                                .addComponent(jLabelPricePerCourse)
                                .addGap(4, 4, 4)
                                .addComponent(jTextFieldPricePerCourse, javax.swing.GroupLayout.PREFERRED_SIZE, 72, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(38, 38, 38)
                                .addComponent(jButtonGenerateTuition, javax.swing.GroupLayout.PREFERRED_SIZE, 153, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanelBottomLayout.createSequentialGroup()
                                .addComponent(jLabelCoursePerWeek)
                                .addGap(4, 4, 4)
                                .addComponent(jTextFieldCoursePerWeek, javax.swing.GroupLayout.PREFERRED_SIZE, 72, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(38, 38, 38)
                                .addComponent(jButtonGenerateCount)))
                        .addGap(17, 17, 17)
                        .addGroup(jPanelBottomLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabelCount)
                            .addComponent(jLabelTuition)
                            .addComponent(jLabelOtherFee))
                        .addGap(18, 18, 18)
                        .addGroup(jPanelBottomLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jTextFieldCount, javax.swing.GroupLayout.PREFERRED_SIZE, 72, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jTextFieldTuition, javax.swing.GroupLayout.PREFERRED_SIZE, 72, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jTextFieldOtherFee, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanelBottomLayout.createSequentialGroup()
                        .addGap(570, 570, 570)
                        .addComponent(jLabel2))
                    .addGroup(jPanelBottomLayout.createSequentialGroup()
                        .addGap(569, 569, 569)
                        .addComponent(jLabel5))
                    .addGroup(jPanelBottomLayout.createSequentialGroup()
                        .addGap(365, 365, 365)
                        .addComponent(jLabel6)))
                .addGap(99, 99, 99))
        );
        jPanelBottomLayout.setVerticalGroup(
            jPanelBottomLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelBottomLayout.createSequentialGroup()
                .addGap(17, 17, 17)
                .addGroup(jPanelBottomLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelBottomLayout.createSequentialGroup()
                        .addGap(3, 3, 3)
                        .addComponent(jLabelCoursePerWeek))
                    .addComponent(jTextFieldCoursePerWeek, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanelBottomLayout.createSequentialGroup()
                        .addGap(3, 3, 3)
                        .addComponent(jButtonGenerateCount))
                    .addGroup(jPanelBottomLayout.createSequentialGroup()
                        .addGap(3, 3, 3)
                        .addComponent(jLabelCount))
                    .addGroup(jPanelBottomLayout.createSequentialGroup()
                        .addGap(3, 3, 3)
                        .addComponent(jTextFieldCount, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(15, 15, 15)
                .addGroup(jPanelBottomLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelBottomLayout.createSequentialGroup()
                        .addGap(3, 3, 3)
                        .addComponent(jLabelPricePerCourse))
                    .addComponent(jTextFieldPricePerCourse, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanelBottomLayout.createSequentialGroup()
                        .addGap(2, 2, 2)
                        .addComponent(jButtonGenerateTuition))
                    .addGroup(jPanelBottomLayout.createSequentialGroup()
                        .addGap(2, 2, 2)
                        .addComponent(jLabelTuition))
                    .addGroup(jPanelBottomLayout.createSequentialGroup()
                        .addGap(2, 2, 2)
                        .addGroup(jPanelBottomLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jTextFieldTuition, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel2))))
                .addGap(15, 15, 15)
                .addGroup(jPanelBottomLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelBottomLayout.createSequentialGroup()
                        .addGap(3, 3, 3)
                        .addComponent(jLabelCostumeFee))
                    .addComponent(jTextFieldCostumeFee, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanelBottomLayout.createSequentialGroup()
                        .addGap(3, 3, 3)
                        .addComponent(jLabel3))
                    .addGroup(jPanelBottomLayout.createSequentialGroup()
                        .addGap(3, 3, 3)
                        .addComponent(jLabelBookFee))
                    .addComponent(jTextFieldBookFee, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanelBottomLayout.createSequentialGroup()
                        .addGap(3, 3, 3)
                        .addComponent(jLabel4))
                    .addGroup(jPanelBottomLayout.createSequentialGroup()
                        .addGap(2, 2, 2)
                        .addComponent(jLabelOtherFee))
                    .addGroup(jPanelBottomLayout.createSequentialGroup()
                        .addGap(2, 2, 2)
                        .addGroup(jPanelBottomLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jTextFieldOtherFee, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(jPanelBottomLayout.createSequentialGroup()
                                .addGap(1, 1, 1)
                                .addComponent(jLabel5)))))
                .addGap(8, 8, 8)
                .addGroup(jPanelBottomLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jButtonGenerateSumFee)
                    .addGroup(jPanelBottomLayout.createSequentialGroup()
                        .addGap(2, 2, 2)
                        .addComponent(jLabelSumFee))
                    .addGroup(jPanelBottomLayout.createSequentialGroup()
                        .addGap(2, 2, 2)
                        .addComponent(jTextFieldSumFee, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanelBottomLayout.createSequentialGroup()
                        .addGap(2, 2, 2)
                        .addComponent(jLabel6))))
        );

        jLabelId.setFont(new java.awt.Font("华文细黑", 0, 24)); // NOI18N
        jLabelId.setText("学生编码");

        jTextFieldId.setFont(new java.awt.Font("华文细黑", 0, 24)); // NOI18N

        jLabelName.setFont(new java.awt.Font("华文细黑", 0, 24)); // NOI18N
        jLabelName.setText("姓名");

        jTextFieldName.setFont(new java.awt.Font("华文细黑", 0, 24)); // NOI18N

        jButtonConfirm.setFont(new java.awt.Font("华文细黑", 0, 24)); // NOI18N
        jButtonConfirm.setText("确定");
        jButtonConfirm.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonConfirmActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                            .addComponent(jPanelBottom, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jButtonConfirm)))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(31, 31, 31)
                        .addComponent(jLabelId)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTextFieldId, javax.swing.GroupLayout.PREFERRED_SIZE, 151, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabelName)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jTextFieldName, javax.swing.GroupLayout.PREFERRED_SIZE, 121, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(22, 22, 22)
                        .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(44, 44, 44)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelId)
                    .addComponent(jTextFieldId, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabelName)
                    .addComponent(jTextFieldName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(10, 10, 10)
                .addComponent(jPanelBottom, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jButtonConfirm)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButtonGenerateEndDateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonGenerateEndDateActionPerformed
        // TODO add your handling code here:
        int gap = 7 * Integer.valueOf(this.jTextFieldWeekCount.getText());
        int year = Integer.valueOf(this.jComboBoxYearStart.getSelectedItem().toString());
        int month = Integer.valueOf(this.jComboBoxMonthStart.getSelectedItem().toString());
        int day = Integer.valueOf(this.jComboBoxDayStart.getSelectedItem().toString());
        this.jTextFieldEndDate.setText(formalStuInputMethod.getEndDate(year, month, day, gap));
}//GEN-LAST:event_jButtonGenerateEndDateActionPerformed

    private void jTextFieldCoursePerWeekActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFieldCoursePerWeekActionPerformed
        // TODO add your handling code here:
        int weekCount = Integer.valueOf(this.jTextFieldWeekCount.getText());
        int coursePerWeek = Integer.valueOf(this.jTextFieldCoursePerWeek.getText());
        int count = weekCount * coursePerWeek;
        this.jTextFieldCount.setText(Integer.toString(count));
}//GEN-LAST:event_jTextFieldCoursePerWeekActionPerformed

    private void jButtonGenerateCountActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonGenerateCountActionPerformed
        // TODO add your handling code here:
        int weekCount = Integer.valueOf(this.jTextFieldWeekCount.getText());
        int coursePerWeek = Integer.valueOf(this.jTextFieldCoursePerWeek.getText());
        int count = weekCount * coursePerWeek;
        this.jTextFieldCount.setText(Integer.toString(count));
}//GEN-LAST:event_jButtonGenerateCountActionPerformed

    private void jTextFieldPricePerCourseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFieldPricePerCourseActionPerformed
        // TODO add your handling code here:
        int pricePerCourse = Integer.valueOf(this.jTextFieldPricePerCourse.getText());
        int count = Integer.valueOf(this.jTextFieldCount.getText());
        int tuition = pricePerCourse * count;
        this.jTextFieldTuition.setText(Integer.toString(tuition));
}//GEN-LAST:event_jTextFieldPricePerCourseActionPerformed

    private void jButtonGenerateTuitionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonGenerateTuitionActionPerformed
        // TODO add your handling code here:
        int pricePerCourse = Integer.valueOf(this.jTextFieldPricePerCourse.getText());
        int count = Integer.valueOf(this.jTextFieldCount.getText());
        int tuition = pricePerCourse * count;
        this.jTextFieldTuition.setText(Integer.toString(tuition));
}//GEN-LAST:event_jButtonGenerateTuitionActionPerformed

    private void jTextFieldOtherFeeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFieldOtherFeeActionPerformed
        // TODO add your handling code here:
        int tuition = Integer.valueOf(this.jTextFieldTuition.getText());
        int costumeFee = Integer.valueOf(this.jTextFieldCostumeFee.getText());
        int bookFee = Integer.valueOf(this.jTextFieldBookFee.getText());
        int otherFee = Integer.valueOf(this.jTextFieldOtherFee.getText());
        int sumFee = tuition + costumeFee + bookFee + otherFee;
        this.jTextFieldSumFee.setText(Integer.toString(sumFee));
}//GEN-LAST:event_jTextFieldOtherFeeActionPerformed

    private void jButtonGenerateSumFeeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonGenerateSumFeeActionPerformed
        // TODO add your handling code here:
        int tuition = Integer.valueOf(this.jTextFieldTuition.getText());
        int costumeFee = Integer.valueOf(this.jTextFieldCostumeFee.getText());
        int bookFee = Integer.valueOf(this.jTextFieldBookFee.getText());
        int otherFee = Integer.valueOf(this.jTextFieldOtherFee.getText());
        int sumFee = tuition + costumeFee + bookFee + otherFee;
        this.jTextFieldSumFee.setText(Integer.toString(sumFee));
}//GEN-LAST:event_jButtonGenerateSumFeeActionPerformed

    private void jButtonConfirmActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonConfirmActionPerformed
        try {
            // TODO add your handling code here:
            DbOperation db = new DbOperation();
            db.DbConnect();
            String sql = "select * from formalStu where id='" + student.id + "'";
            ResultSet rs = db.DBSqlQuery(sql);
            if (rs.next()) {
                boolean flag = false;

                rs.updateString("weekCount", this.jTextFieldWeekCount.getText());
                student.weekCount = this.jTextFieldWeekCount.getText();

                rs.updateString("dateStart", this.jComboBoxYearStart.getSelectedItem().toString() + "." + this.jComboBoxMonthStart.getSelectedItem().toString() + "." + this.jComboBoxDayStart.getSelectedItem().toString());
                student.dateStart = this.jComboBoxYearStart.getSelectedItem().toString() + "." + this.jComboBoxMonthStart.getSelectedItem().toString() + "." + this.jComboBoxDayStart.getSelectedItem().toString();

                rs.updateString("coursePerWeek", this.jTextFieldCoursePerWeek.getText());
                student.coursePerWeek = this.jTextFieldCoursePerWeek.getText();

                rs.updateString("pricePerCourse", this.jTextFieldPricePerCourse.getText());
                student.pricePerCourse = this.jTextFieldPricePerCourse.getText();

                rs.updateString("tuition", this.jTextFieldTuition.getText());
                student.tuition = this.jTextFieldTuition.getText();

                rs.updateString("bookFee", this.jTextFieldBookFee.getText());
                student.bookFee = this.jTextFieldBookFee.getText();

                rs.updateString("costumeFee", this.jTextFieldCostumeFee.getText());
                student.costumeFee = this.jTextFieldCostumeFee.getText();

                rs.updateString("otherFee", this.jTextFieldOtherFee.getText());
                if (rs.getString("sumFee").equals(this.jTextFieldSumFee.getText()) == false) {//总费用发生变化，证明是二次交费
                    rs.updateString("first", "false");//二次交费的标记                    
                    flag = true;
                }
                rs.updateString("sumFee", this.jTextFieldSumFee.getText());
                student.sumFee = this.jTextFieldSumFee.getText();

                rs.updateRow();
                JOptionPane.showConfirmDialog(null, "修改成功！", "提示", JOptionPane.CLOSED_OPTION, JOptionPane.INFORMATION_MESSAGE);

                if (flag) {//如果费用发生变化才需打印收据
                    int result = JOptionPane.showConfirmDialog(null, "要打印收据吗？", "提示", JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE);
                    String filename;
                    filename = this.jTextFieldName.getText() + ".xls";
                    NewRecipeExcel put = new NewRecipeExcel(student, filename);
                    put.setOutputFile(filename);
                    put.write();
                    if (result == 0) {
                        PrintTest.print(PrintTest.getPath() + "\\学生证和收据\\" + filename);
                    } else {
                        PrintTest.showTable(PrintTest.getPath() + "\\学生证和收据\\" + filename);
                    }
                    System.out.println("Please check the result file " + PrintTest.getPath() + "\\学生证和收据\\" + filename);
                }
                dispose();
            }
        } catch (IOException ex) {
            Logger.getLogger(feeDialog.class.getName()).log(Level.SEVERE, null, ex);
        } catch (WriteException ex) {
            Logger.getLogger(feeDialog.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SQLException ex) {
            Logger.getLogger(feeDialog.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_jButtonConfirmActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /*  java.awt.EventQueue.invokeLater(new Runnable() {
        
        public void run() {
        feeDialog dialog = new feeDialog(new javax.swing.JFrame(), true);
        dialog.addWindowListener(new java.awt.event.WindowAdapter() {
        
        public void windowClosing(java.awt.event.WindowEvent e) {
        System.exit(0);
        }
        });
        dialog.setVisible(true);
        }
        });*/
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButtonConfirm;
    private javax.swing.JButton jButtonGenerateCount;
    private javax.swing.JButton jButtonGenerateEndDate;
    private javax.swing.JButton jButtonGenerateSumFee;
    private javax.swing.JButton jButtonGenerateTuition;
    private javax.swing.JComboBox jComboBoxDayStart;
    private javax.swing.JComboBox jComboBoxMonthStart;
    private javax.swing.JComboBox jComboBoxYearStart;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabelBookFee;
    private javax.swing.JLabel jLabelCostumeFee;
    private javax.swing.JLabel jLabelCount;
    private javax.swing.JLabel jLabelCoursePerWeek;
    private javax.swing.JLabel jLabelDateStart;
    private javax.swing.JLabel jLabelDayStart;
    private javax.swing.JLabel jLabelId;
    private javax.swing.JLabel jLabelMonthStart;
    private javax.swing.JLabel jLabelName;
    private javax.swing.JLabel jLabelOtherFee;
    private javax.swing.JLabel jLabelPricePerCourse;
    private javax.swing.JLabel jLabelSumFee;
    private javax.swing.JLabel jLabelTuition;
    private javax.swing.JLabel jLabelWeekCount;
    private javax.swing.JLabel jLabelYearStart;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanelBottom;
    private javax.swing.JTextField jTextFieldBookFee;
    private javax.swing.JTextField jTextFieldCostumeFee;
    private javax.swing.JTextField jTextFieldCount;
    private javax.swing.JTextField jTextFieldCoursePerWeek;
    private javax.swing.JTextField jTextFieldEndDate;
    private javax.swing.JTextField jTextFieldId;
    private javax.swing.JTextField jTextFieldName;
    private javax.swing.JTextField jTextFieldOtherFee;
    private javax.swing.JTextField jTextFieldPricePerCourse;
    private javax.swing.JTextField jTextFieldSumFee;
    private javax.swing.JTextField jTextFieldTuition;
    private javax.swing.JTextField jTextFieldWeekCount;
    // End of variables declaration//GEN-END:variables
}
